package com.demo.employee;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name="EMPLOYEE")
// persistent class means object of this class can be persisted into 
// database.  
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class EmployeeDTO {

	private int id;
	private String name;
	private int age;
	private String department;
	
	/*private  Collection<Address> addresses=new HashSet<Address>();
	*/
	//type registry   org.hibernate.type.Type
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return id;
	}
    
	public String getName() {
		return name;
	}

	public int getAge() {
		return age;
	}
	
	@Column(name="DEPT",columnDefinition="varchar(50) default 'IT'")
	public String getDepartment() {
		return department;
	}
  
	/*//composite value type  embded type 
	@ElementCollection(fetch=FetchType.EAGER)
	@JoinTable(name="EMPLOYEE_ADDRESS", joinColumns=@JoinColumn(name="EMP_ID"))
	public Collection<Address> getAddresses() {
		return addresses;
	
	}
	
	
	public void setAddresses(Collection<Address> addresses) {
		this.addresses = addresses;
	}
*/
	

	public void setId(int id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAge(int age) {
		this.age = age;
	}
	public void setDepartment(String department) {
		this.department = department;
	}

	@Override
	public String toString() {
		return "EmployeeDTO [id=" + id + ", name=" + name + ", age=" + age
				+ "]";
	}
	
	
	
}
